<?php

namespace Kateba\SiteBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Comment
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="Kateba\SiteBundle\Entity\CommentRepository")
 */
class Comment {

    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var \Kateba\SiteBundle\Entity\Post
     *
     * @ORM\ManyToOne(targetEntity="\Kateba\SiteBundle\Entity\Post", inversedBy="comments")
     * @ORM\JoinColumn(name="post_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)
     */
    private $post;

    /**
     * @var \Kateba\UserBundle\Entity\User
     *
     * @ORM\ManyToOne(targetEntity="\Kateba\UserBundle\Entity\User", inversedBy="comments")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)
     */
    private $user;

    /**
     * @var string
     * @Assert\NotBlank
     * @Assert\MinLength(limit=2)
     * @ORM\Column(name="comment", type="text")
     */
    private $comment;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="createdAt", type="datetime")
     */
    private $createdAt;

    public function __toString() {
        return (string) $this->comment;
    }

    public function __construct() {
        $this->createdAt = new \DateTime();
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId() {
        return $this->id;
    }

    /**
     * Set comment
     *
     * @param string $comment
     * @return Comment
     */
    public function setComment($comment) {
        $this->comment = $comment;

        return $this;
    }

    /**
     * Get comment
     *
     * @return string
     */
    public function getComment() {
        return $this->comment;
    }

    /**
     * Set createdAt
     *
     * @param \DateTime $createdAt
     * @return Post
     */
    public function setCreatedAt($createdAt) {
        $this->createdAt = $createdAt;

        return $this;
    }

    /**
     * Get createdAt
     *
     * @return \DateTime
     */
    public function getCreatedAt() {
        return $this->createdAt;
    }

    /**
     * Set post
     *
     * @param \Kateba\SiteBundle\Entity\Post $post
     * @return Comment
     */
    public function setPost(\Kateba\SiteBundle\Entity\Post $post) {
        $this->post = $post;

        return $this;
    }

    /**
     * Get post
     *
     * @return \Kateba\SiteBundle\Entity\Post
     */
    public function getPost() {
        return $this->post;
    }

    /**
     * Set user
     *
     * @param \Kateba\UserBundle\Entity\User $user
     * @return Comment
     */
    public function setUser(\Kateba\UserBundle\Entity\User $user) {
        $this->user = $user;

        return $this;
    }

    /**
     * Get user
     *
     * @return \Kateba\UserBundle\Entity\User
     */
    public function getUser() {
        return $this->user;
    }

}